package com.ssy.lingxi.product.serviceImpl.saleorder.invoicestype;

import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.enhance.api.feign.ProduceNoticeOrderControllerFeign;
import com.ssy.lingxi.product.api.model.request.warehouse.InvoicesAddRequest;
import com.ssy.lingxi.product.api.model.request.warehouse.InvoicesUpdataRequest;
import com.ssy.lingxi.product.entity.warehouse.Invoices;
import com.ssy.lingxi.product.service.saleorder.invoicestype.InvoicesTypeStrategy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* 加工入库单
* @author wrc
* @date 2020/12/21
*/
@Service("processingInvoice")
public class ProcessingInvoiceImpl implements InvoicesTypeStrategy {

    @Resource
    ProduceNoticeOrderControllerFeign produceNoticeOrderControllerFeign;
    /**
     * 添加单据-加工入库单
     */
    @Override
    public Wrapper invoicesAdd(Invoices invoices, InvoicesAddRequest request, UserLoginCacheDTO sysUser) {
        return null;
    }

    /**
     * 修改单据-加工发货单
     */
    @Override
    public Wrapper invoicesUpdata(Invoices invoices, InvoicesUpdataRequest request) {
//        List<UpdateInvoiceDTO.InvoiceDetailsDTO> collect = request.getInvoicesDetailsRequests().stream().map(temp -> {
//            UpdateInvoiceDTO.InvoiceDetailsDTO invoiceDetailsDTO = new UpdateInvoiceDTO.InvoiceDetailsDTO();
//            BeanUtils.copyProperties(temp,invoiceDetailsDTO);
//            invoiceDetailsDTO.setProduceNoticeOrderDetailId(temp.getProduceNoticeOrderDetailId());
//            return invoiceDetailsDTO;
//        }).collect(Collectors.toList());
//        UpdateInvoiceDTO batchExamDTO=new UpdateInvoiceDTO();
//        batchExamDTO.setDeliveryId(invoices.getId());
//        batchExamDTO.setInvoiceDetailsDTOList(collect);
//        batchExamDTO.setProduceNoticeOrderId(invoices.getRelevanceInvoicesId());
//       return produceNoticeOrderControllerFeign.updateDelivery(batchExamDTO);
        return  Wrapper.success();
    }

    /**
     * 批量审核单据
     * @author wrc
     * @date 2020/12/29
     */
    @Override
    public Wrapper invoicesReviewAll(List<Invoices> invoicess, UserLoginCacheDTO sysUser) {
//        BatchExamDTO batchExamDTO = new BatchExamDTO();
//        batchExamDTO.setIdList(invoicess.stream().map(Invoices::getId).collect(Collectors.toList()));
//        batchExamDTO.setUser(sysUser);
//        return produceNoticeOrderControllerFeign.batchExamStorage(batchExamDTO);
        return  Wrapper.success();
    }
}
